package com.yunji.order.bo;

import com.yunji.common.base.PageDTO;
import com.yunji.common.utils.bean.BeanUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author : peter-zhu
 * @date : 2024/12/18 13:55
 * @description : TODO
 **/
@EqualsAndHashCode(callSuper = true)
@Data
public class ListOrderMemberBO extends PageDTO {
    private Long memberId;
    private Integer readStatus;

    @ApiModelProperty("订单状态数组")
    private List<Integer> orderStatusList;

    @ApiModelProperty("字符型订单状态")
    private String orderStatusArray;

    @ApiModelProperty("查看已售后订单 查询全部就不传或null 查无售后传0 查有售后传1")
    private Integer refund;

    public ListOrderMemberBO() {
    }

    public List<Integer> getOrderStatusList() {
        if (BeanUtils.isNotNull(getOrderStatusArray()) && !getOrderStatusArray().isEmpty()) {
            String[] array = getOrderStatusArray().split("_");
            return Arrays.stream(array)
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());
        }
        return orderStatusList;
    }

    public ListOrderMemberBO(Long memberId, Integer readStatus) {
        this.memberId = memberId;
        this.readStatus = readStatus;
    }
}
